<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
	<meta content="yes" name="apple-mobile-web-app-capable" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<meta content="telephone=no" name="format-detection" />
	<meta content="emai=no" name="format-detection" />
	<link rel="stylesheet" type="text/css" href="/quiz/css/swiper.min.css">
	<link rel="stylesheet" type="text/css" href="/quiz/css/common.css" />
	<link rel="stylesheet" type="text/css" href="/quiz/css/coupon.css" />
	<script src="/quiz/js/zepto-1.1.6.js" type="text/javascript"></script>
	<script src="/quiz/js/fastclick.js" type="text/javascript"></script>
	<script src="/quiz/js/common.js" type="text/javascript"></script>
	<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script src="/quiz/js/swiper.min.js"></script>
	<title>【我不管，你最棒】五星★大奖赛！</title>
	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "//hm.baidu.com/hm.js?19f39b206aedf768b42fbc69e4e4f721";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>
</head>
<body>
	<div class="wrapper">
		<header>
			<img src="/quiz/img/head.png" alt="我不管你最棒五星大奖赛" />
		</header>
		<div>
			<img src="/quiz/img/txt_coupon.png" />
			<?php if($row['default'] == 1):?>
			<section class="done" id="default_coupon">
				<img src="/quiz/img/bg_cpdone.png" />
				<span>50</span>
			</section>
			<?php else:?>
			<section class="todo"  id="default_coupon">
				<img src="/quiz/img/bg_cptodo.png" />
				<span>50</span>
			</section>
			<?php endif;?>
			
			<?php if($row['share'] == 1):?>
			<section class="done" >
				<img src="/quiz/img/bg_cpdone.png" />
				<span>100</span>
			</section>
			<?php else:?>
			<section class="todo" data-spopup=".share-notice" id="do_share">
				<img src="/quiz/img/bg_cptodo.png" />
				<span>100</span>
			</section>
			<?php endif;?>
			<a href="/shop/mobile">
				<img src="/quiz/img/btn_use.png" />
			</a>
		</div>
		<footer>
			<img src="/quiz/img/bg_share.png" />
		</footer>
	</div>
	<div class="popup-wrapper share-notice">
		<div class="popup-bg" data-cpopup=".share-notice"></div>
		<div class="popup-layout" data-cpopup=".share-notice">
			<img class="share" src="/quiz/img/share_notice.png" />
		</div>
	</div>
	<div class="popup-wrapper follow-notice">
		<div class="popup-bg" data-cpopup=".follow-notice"></div>
		<div class="popup-layout" data-cpopup=".follow-notice">
			<img src="/quiz/img/qrcode.png" />
		</div>
	</div>
	<script type="text/javascript">
    Zepto(function ($) {

		$("#default_coupon").click(function(){
		 $.ajax({
 				url: "/qa/ajaxcoupon",
 				data: {type: 1},
 				type: "post",
 				dataType: "json",
 				success: function(res){
 					if(res.error == 0)
     				{
         				$("#default_coupon").attr("class", "done");
         				$("#default_coupon").find("img").attr("src", "/quiz/img/bg_cpdone.png");

         				$("#do_share").attr("data-spopup", "");
     				}
 					else
 					{
 						if(res.error == 3)
        					$(".follow-notice").show();
 					}
 				}
 		    });
		});
        
        wx.config({
            debug: false,
            appId: '<?php echo $js_config['appId']?>',
            timestamp: <?php echo $js_config['timestamp']?>,
            nonceStr: '<?php echo $js_config['noncestr']?>',
            signature: '<?php echo $js_config['signature']?>',
            jsApiList: [
            	'onMenuShareTimeline',
            	'onMenuShareAppMessage'
            ]
        });
        wx.ready(function () {
        	wx.onMenuShareTimeline({
            	title: '<?php echo $share_title;?>',
        	    link: '<?php echo $share_url?>', // 分享链接
        	    imgUrl: 'http://wx.zhishimama.com/quiz/img/share.jpg', // 分享图标
        	    success: function () {
        	        // 用户确认分享后执行的回调函数
        	        $.ajax({
        				url: "/qa/ajaxcoupon",
        				data: {type: 2},
        				type: "post",
        				dataType: "json",
        				success: function(res){
        					if(res.error == 0)
            				{
                				$("#do_share").attr("class", "done");
                				$("#do_share").find("img").attr("src", "/quiz/img/bg_cpdone.png");

                				$("#do_share").attr("data-spopup", "");
            				}
        					else
        					{
            					if(res.error == 3)
                					$(".follow-notice").show();
        					}
        				}
        		    });
        	    },
        	    cancel: function () {
        	        // 用户取消分享后执行的回调函数
        	    }
        	});

        	wx.onMenuShareAppMessage({
            	title: '<?php echo $share_title?>',
        	    desc: '<?php echo $share_desc;?>', // 分享描述
        	    link: '<?php echo $share_url?>', // 分享链接
        	    imgUrl: 'http://wx.zhishimama.com/quiz/img/share.jpg', // 分享图标
        	    type: 'link', // 分享类型,music、video或link，不填默认为link
        	    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
        	    success: function () {
        	        // 用户确认分享后执行的回调函数
        	    	$.ajax({
        				url: "/qa/ajaxcoupon",
        				data: {type: 2},
        				type: "post",
        				dataType: "json",
        				success: function(res){
            				if(res.error == 0)
            				{
                				$("#do_share").attr("class", "done");
                				$("#do_share").find("img").attr("src", "/quiz/img/bg_cpdone.png");
            				}
            				else
            				{
            					if(res.error == 3)
                					$(".follow-notice").show();
            				}
        				}
        		    });
        	    },
        	    cancel: function () {
        	        // 用户取消分享后执行的回调函数
        	    }
        	});
        });
    })
	</script>
</body>
</html>
